<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Home extends CI_Controller {

    // +----------------------------------------------------------
    // | Trainingsessies
    // +----------------------------------------------------------
    // | KHK - 2 TI4 - 2014-2015
    // +----------------------------------------------------------
    // | Home Controller
    // |
    // +----------------------------------------------------------
    // | Nicola Beysen
    // +----------------------------------------------------------

    public function __construct() {
        parent::__construct();
        $this->load->helper('form');
    }

    //Home pagina
    public function index() {

        $data['user'] = $this->authex->getUserInfo();
        $data['activeItem'] = 'Home';

        $partials = array('header' => 'main_header',
            'content' => 'home',
            'footer' => 'main_footer',
            'topmenu' => 'main_topmenu',
            'sidemenu' => 'main_sidemenu',
            'script' => 'main_script');

        $this->template->load('main_master', $partials, $data);
    }

    //Contact pagina
    public function contact() {

        $data['user'] = $this->authex->getUserInfo();
        $data['activeItem'] = 'Contact';

        $partials = array('header' => 'main_header',
            'content' => 'contact/contact',
            'footer' => 'main_footer',
            'topmenu' => 'main_topmenu',
            'sidemenu' => 'main_sidemenu',
            'script' => 'main_script');

        $this->template->load('main_master', $partials, $data);
    }

    //login pagina
    public function login() {
        $data['user'] = $this->authex->getUserInfo();
        $data['activeItem'] = 'Aanmelden';

        $partials = array('header' => 'main_header',
            'content' => 'login/login_login',
            'footer' => 'main_footer',
            'topmenu' => 'main_topmenu',
            'sidemenu' => 'main_sidemenu',
            'script' => 'main_script');
        $this->template->load('main_master', $partials, $data);
    }

    //fout bij inloggen pagina
    public function fout() {
        $data['user'] = $this->authex->getUserInfo();
        $data['activeItem'] = 'Aanmelden';

        $partials = array('header' => 'main_header',
            'content' => 'login/login_fout',
            'footer' => 'main_footer',
            'topmenu' => 'main_topmenu',
            'sidemenu' => 'main_sidemenu',
            'script' => 'main_script');
        $this->template->load('main_master', $partials, $data);
    }

    public function aanmelden() {
        $gebruikersnaam = $this->input->post('gebruikersnaam');
        $wachtwoord = $this->input->post('wachtwoord');

        if ($this->authex->login($gebruikersnaam, $wachtwoord)) {
            redirect('home/index');
        } else {
            redirect('home/fout');
        }
    }

    public function afmelden() {
        $this->authex->logout();
        redirect('home/index');
    }

    public function geentoegang() {
        $data['user'] = $this->authex->getUserInfo();
        $data['activeItem'] = 'Aanmelden';

        $partials = array('header' => 'main_header',
            'content' => 'login/login_geentoegang',
            'footer' => 'main_footer',
            'topmenu' => 'main_topmenu',
            'sidemenu' => 'main_sidemenu',
            'script' => 'main_script');
        $this->template->load('main_master', $partials, $data);
    }

}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */